package mr

//
// RPC definitions.
//
// remember to capitalize all names.
//

import "os"
import "strconv"

//
// example to show how to declare the arguments
// and reply for an RPC.
//
/*
RequestType:
	0: 获取任务
	1: 任务已经完成
	2:
*/
type MapArgs struct {
	RequestType int
}

/*
Status: 任务分配状态
	0: 正常分配
	1: 无任务分配
TaskId: 任务名
*/
type MapReply struct {
	Status   int
	Filename string
	Workid   int
	NReduce  int
}

type MapDoneArgs struct {
	Workid int
	Files  string
}
type MapDoneReply struct {
	Status int
}

type ReduceArgs struct {
}

type ReduceReply struct {
	Start    bool
	Files    string
	ReduceId int
	Status   int
}

type ReduceDoneArgs struct {
	Workid int
	File   string
}

type ReduceDoneReply struct {
	Status int
}

type DoneArgs struct {
	Reduceid int
}

const (
	// 请求错误
	ERROR = iota
	// 请求成功,继续请求
	SUCCESS
	// 进入下一步
	NEXT
	// 休眠，1s钟之后继续请求
	HOLDON
)

// Add your RPC definitions here.

// Cook up a unique-ish UNIX-domain socket name
// in /var/tmp, for the master.
// Can't use the current directory since
// Athena AFS doesn't support UNIX-domain sockets.
func masterSock() string {
	s := "/var/tmp/824-mr-"
	s += strconv.Itoa(os.Getuid())
	return s
}
